package cn.jtool.dig.server.comm;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 虚拟通道管理
 */
public class VirtualChannelManager {

    private final static Map<Long, VirtualChannel> virtualChannels = Maps.newConcurrentMap();

    public static void addVirtualChannel(long virtualChannelId, int tunnelChanelId) {
        virtualChannels.put(virtualChannelId, new VirtualChannel(virtualChannelId, tunnelChanelId, System.currentTimeMillis()));
    }

    public static VirtualChannel getVirtualChannelByVirtualChannelId(long virtualChannelId){
        return virtualChannels.get(virtualChannelId);
    }

    public static void removeVirtualChannel(long virtualChannelId) {
        virtualChannels.remove(virtualChannelId);
    }

}
